package com.example.swagger.mapper;

import com.example.swagger.entity.BookEntity;
import com.example.swagger.entity.Order;
import com.example.swagger.entity.User;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper

public interface OrderMapper {

    @Select("SELECT * FROM t_order")
    public List<Order> getOrders();

    @Select("SELECT * FROM t_order")
    public PageInfo<Order> getOrdersByPage(@Param("pageNo") Integer pageNo, @Param("pageSize") Integer pageSize);

    @Insert("INSERT INTO t_order(id, orderId, orderName,price, content, createTime, updateTime,orderNo) VALUES (#{id},#{orderId},#{orderName},#{price},#{content},#{createTime},#{updateTime},#{orderNo})")
    void insertOrder(@Param("id") Integer id,@Param("orderId") String orderId,@Param("orderName") String orderName,@Param("price") float price,@Param("content") String content,@Param("createTime") Date createTime,@Param("updateTime") Date updateTime,@Param("orderNo") String orderNo);

    @Select("SELECT * FROM t_order WHERE id=#{id}")
    public Order findOrderById(Integer id);

    @Delete("DELETE FROM t_order WHERE id = ${id}")
    void deleteOrder(@Param("id") Integer id);

    @Update("update t_order set orderId=#{orderId}, orderName=#{orderName},price=#{price}, content=#{content}, createTime=#{createTime}, updateTime=#{updateTime}, orderNo=#{orderNo} WHERE id=#{id}")
    void updateOrder(@Param("id") Integer id,@Param("orderId") String orderId,@Param("orderName") String orderName,@Param("price") float price,@Param("content") String content,@Param("createTime") Date createTime,@Param("updateTime") Date updateTime,@Param("orderNo") String orderNo);
}
